package com.superzqb.asus.superzqbFragment.superzqbJobShop.Shop.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.superzqb.asus.superzqb.R;
import com.superzqb.asus.superzqbFragment.superzqbJobShop.Shop.Bean.CommentBean;
import com.superzqb.asus.superzqbUtil.GenCommentsAdapter;

import java.util.List;

/**
 * Created by asus on 2017/4/24.
 */

public class CommentAdapter extends BaseAdapter {
    private Context context;
    private List<CommentBean> items;
    public CommentAdapter(Context context,List<CommentBean> list){
        this.context=context;
        this.items=list;
    }
    public void setList(List<CommentBean> list){
        this.items=list;

    }
    @Override
    public int getCount() {
        return items==null?0:items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if(convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.comments_item,parent,false);
            convertView.setTag(new CommentAdapter.Holder(convertView));
        }
        CommentAdapter.Holder holder= (CommentAdapter.Holder )convertView.getTag();
        CommentBean item=items.get(position);
        holder.content.setText(item.getContent());
        holder.time.setText(item.getCreatetime());
        holder.user.setText(item.getU_id());
        return convertView;
    }
     class Holder{
        private TextView user,content,time;
        public Holder(View view){
            user=(TextView)view.findViewById(R.id.user);
            content=(TextView)view.findViewById(R.id.content);
            time=(TextView)view.findViewById(R.id.time);
        }

    }
}
